//Snatch3 script by SteelRat (Truck section borrowed from SD's Goldrush map)
//mortis bugfix script - 13 Jun 2006 23:07:15 PDT - extensive bugfixes and spawn mangling
//mortis competition changes - 19 Jun 2006 12:52:20 PDT - Version 1 remove bridge, truck barriers, MG nests and related TWOs
//mortis added 30-20 axis-allied spawn times, reduced map duration to 15 minutes
//antman copied the above mortis fixes from snatch2 competition script and removed the voice announcements for the barriers

game_manager
{
	spawn
	{
	
		//mortis sloppy script fix - remove bad TWO, bad bluespawns, add new bluespawns, good TWO

		create
		{
			scriptName "snatchhq_obj"
			classname "team_WOLF_objective"
			targetname "snatchhq_obj"
			origin "-824 -1966 318"	// z = CC_FILTER_ALLIES(2) | CC_FILTER_SPAWNS(4)
			spawnflags 2	// TEAM_ALLIES(2)
		}

		create
		{
			scriptName "snatchhq_spawn1"
			classname "team_CTF_bluespawn"
			targetname "snatchhq_spawn"
			origin "-896 -1792 198"
			spawnflags 2	// TEAM_ALLIES
		}

		create
		{
			scriptName "snatchhq_spawn2"
			classname "team_CTF_bluespawn"
			targetname "snatchhq_spawn"
			origin "-896 -1920 202"
			spawnflags 2	// TEAM_ALLIES
		}

		create
		{
			scriptName "snatchhq_spawn3"
			classname "team_CTF_bluespawn"
			targetname "snatchhq_spawn"
			origin "-896 -2048 198"
			spawnflags 2	// TEAM_ALLIES
		}

		create
		{
			scriptName "snatchhq_spawn4"
			classname "team_CTF_bluespawn"
			targetname "snatchhq_spawn"
			origin "-896 -2112 198"
			spawnflags 2	// TEAM_ALLIES
		}

		create
		{
			scriptName "snatchhq_spawn5"
			classname "team_CTF_bluespawn"
			targetname "snatchhq_spawn"
			origin "-768 -1792 202"
			spawnflags 2	// TEAM_ALLIES
		}

		create
		{
			scriptName "snatchhq_spawn6"
			classname "team_CTF_bluespawn"
			targetname "snatchhq_spawn"
			origin "-768 -1846 512"
			spawnflags 2	// TEAM_ALLIES
		}

		create
		{
			scriptName "snatchhq_spawn7"
			classname "team_CTF_bluespawn"
			targetname "snatchhq_spawn"
			origin "-768 -2112 512"
			spawnflags 2	// TEAM_ALLIES
		}

		create
		{
			scriptName "snatchhq_spawn8"
			classname "team_CTF_bluespawn"
			targetname "snatchhq_spawn"
			origin "-786 -2176 512"
			spawnflags 2	// TEAM_ALLIES
		}
		create
		{
			
			scriptname "bridge"
			targetname "bridge"
			classname "func_static"
			origin "0 0 0"
			type "5"
			model "*38"
		}
		delete
		{

			origin "-864 -1966 318"	
	
		}

		delete
		{

			origin "-832 -2082 202"	
	
		}

		delete
		{

			origin "-916 -1826 194"	
	
		}

		delete
		{

			origin "-984 -1890 194"	
	
		}

		delete
		{

			origin "-820 -1822 194"	
	
		}

		delete
		{

			origin "-836 -1910 194"	
	
		}

		delete
		{

			origin "-912 -2114 202"	
	
		}

		delete
		{

			origin "-912 -2014 198"	
	
		}

		delete
		{

			origin "-912 -1942 198"	
	
		}

		delete
		{

			origin "-832 -1994 198"	
	
		}

		delete
		{

			origin "-836 -2154 202"	
	
		}

		delete
		{

			origin "-1004 -1822 194"	
	
		}

		delete
		{

			origin "-744 -2126 202"	
	
		}

		delete
		{

			origin "392 1974 196"	
	
		}
		delete
		{

			origin "868 2438 300"	
	
		}
		//mortis delete health ammo toi
		delete
		{

			targetname "south_hacabinet_toi"	
	
		}

		delete
		{

			targetname "north_hacabinet_toi"	
	
		}



		remapshaderflush
		
		// Game rules
		wm_axis_respawntime	30
		//mortis give allies standard 20 sec spawn
		wm_allied_respawntime	20
		wm_number_of_objectives 7
		//mortis reduce time to reflect missing barriers
		wm_set_round_timelimit	15

		// Current main objectives for each team (0=Axis, 1=Allies)
		wm_set_main_objective		1	0
		wm_set_main_objective		1	1

		wm_objective_status 1 0 1  //Axis Has Radar Parts at map start
		wm_objective_status 1 1 0  //Allies do not have radar parts
		wm_objective_status 2 0 1  //Axis has the truck
		wm_objective_status 2 1 0  //Allies do not have the truck
		wm_objective_status 3 0 1  //The main gate is intact
		wm_objective_status 3 1 0  //Allies have not blown the gate
		wm_objective_status 4 0 1  //Axis has prevented Allies from escaping with the radar parts (so far..)
		wm_objective_status 4 1 0  //Allies have not escapted with the radar parts
		wm_objective_status 5 0 1  //Axis have destroyed the Allied command post
		wm_objective_status 5 1 0  //Allies have not built their command post
		wm_objective_status 6 0 0  //Axis have not built their command post
		wm_objective_status 6 1 1  //Allies have destroyed the Axis command post
		wm_objective_status 7 0 1  //Axis radio wall is ok
		wm_objective_status 7 1 0  //Allies have not destroyed the Radio Wall

		wm_set_main_objective		1	0
		wm_set_main_objective		1	1

		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	0

		// Winner on expiration of round timer (0=Axis, 1=Allies)
		wm_setwinner	0

		setstate alsp1 default
		setstate axsp1 default
		//mortis autospawns must be set before players spawn
		wait 150
		setautospawn	"Base Spawn"	0
		setautospawn	"Allied House"	1
		
		

		globalaccum 2 set 0
		//Controls if Allied spawn will be moved once truck has passed the main gate.
		
		// start triggered loops on/off as required (eg: command post radio sounds)



		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		//mortis
		//wm_addteamvoiceannounce 1 "fueldump_allies_bridge_construct"
		
		wm_addteamvoiceannounce 1 "radar_allies_radars_steal"
		
		wm_addteamvoiceannounce 0 "radar_axis_radars_defend"
				
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"

		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		//mortis		
		//wm_teamvoiceannounce 1 "fueldump_allies_bridge_construct"
		
		wm_teamvoiceannounce 1 "radar_allies_radars_steal"
		
		wm_teamvoiceannounce 0 "radar_axis_radars_defend"
		// *---------------------------------------------------------------------------------*
	}

	trigger allies_win
	{
		wm_setwinner	1
		wm_announce "Allied team escaped with the Radar Parts!"

		wm_objective_status 4 0 2
		wm_objective_status 4 1 1

		wait 1500
		wm_endround
	}
	
}


//mortis
snatchhq_obj
{
	spawn
	{
		set
		{
			//these have to be set inside the spawn{} function, not create{}
			description "Forest House Spawn"
			message "Forest House Spawn"
		}
		wait 50
		setstate snatchhq_obj invisible
		setstate snatchhq_spawn invisible

	}

	trigger on
	{               
		setstate snatchhq_obj default
		setstate snatchhq_spawn default
	}

	trigger off
	{
		setstate snatchhq_obj invisible
		setstate snatchhq_spawn invisible
	}
}

t132
{
	spawn
	{
	wait 20

		set
		{
		allowteams "7"
		}

	}

}
// **********************************************
// ****************** TRUCK STUFF ***************
// **********************************************

truck_smoke
{
	spawn
	{
		wait 300
		attachtotag truck tag_wfront
		setstate truck_smoke invisible
	}
}

// sound "thread"
truck_engine
{
	spawn
	{
		wait 200
		attachtotag truck tag_wfront

		trigger truck_engine sound_idle
	}

	trigger start
	{
		trigger truck_engine sound_start
		wait 950
		trigger truck_engine sound_move
	}

	trigger stop
	{
		trigger truck_engine sound_stop
		wait 950
		trigger truck_engine sound_idle
	}

	// ========================================
	// sound events
	trigger sound_idle
	{
		playsound sound/vehicles/truck/truck_idle.wav looping
	}

	trigger sound_start
	{
		stopsound
		playsound sound/vehicles/truck/truck_revup.wav volume 96
	}

	trigger sound_move
	{
		playsound sound/vehicles/truck/truck_move.wav looping
	}

	trigger sound_stop
	{
		stopsound
		playsound sound/vehicles/truck/truck_revdown.wav volume 96
	}

	trigger sound_death
	{
		stopsound
		playsound sound/vehicles/truck/truck_stop.wav volume 96
	}

	// ========================================
	// ========================================
}

truck_build
{
	spawn
	{
		wait 500

		attachtotag truck tag_wback
	}
}

truck_construct
{
	spawn
	{
		constructible_class 2
		constructible_health 1050
		constructible_constructxpbonus 10
		constructible_destructxpbonus 10
	}

	built final
	{
		alertentity truck

		wm_announce "The Truck has been repaired!"
	}
}

// digibob: ok, for once i'm gonna PLAN this one, so NOTHING WILL BREAK EVAR
// ============================================================================
// accum 0, gold bars collected
// accum 1
//  - bit 0: barrier 1 status 	( 0 = destroyed, 	1 = built 		)
//  - bit 1: barrier 2 status 	( 0 = destroyed, 	1 = built 		)
//  - bit 2: spline status 		( 0 = not moving, 	1 = moving 		)
//  - bit 3: stuck check flag 	( 0 = not stuck, 	1 = stuck 		)
//  - bit 4: script lockout 	( 0 = no lockout, 	1 = lockout		)
//  - bit 5: blank 				( 									)
//  - bit 6: temp register 		(XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
//  - bit 7: death status 		( 0 = alive, 		1 = dead		)
//  - bit 8: player check 		( 0 = players, 		1 = no players	)
//  - bit 9: visible state		( 0 = alive, 		1 = dead		)
// accum 2, blank
// accum 3, current movement loop position
// accum 4, stop counter
// accum 5, blank
// accum 6, blank
// accum 7, blank
// ============================================================================
// spline points are tspln_X with X = 1 to 23
// ============================================================================
// wheel events:
//  - wheels_forward
//  - wheels_backward
//  - wheels_stop

truck
{
	spawn
	{
		faceangles 0 360 0 50
	}

	// ========================================
	// wheeeeeeeeeeeeeeels. eeels. ls.
	trigger wheels_forward
	{
		trigger truck_bwheel2 forward
		trigger truck_fwheel forward
	}

	trigger wheels_backward
	{
		trigger truck_bwheel2 backward
		trigger truck_fwheel backward
	}

	trigger wheels_stop
	{
		trigger truck_bwheel2 stop
		trigger truck_fwheel stop
	}

	// ========================================
	// ========================================

	trigger add_goldbar
	{
		accum 0 inc 1

		trigger gold_full_0 show
		trigger gold_trans_0 hide
		trigger gold_crate secured
		
				
		accum 0 abort_if_less_than 1

		//trigger gold_full_1 show
		//trigger gold_trans_1 hide

		trigger self truck_escape_msg

		wm_announce "Allied team has stolen the Truck!"

		wm_objective_status 1 0 2
		wm_objective_status 1 1 1

		wm_set_main_objective 4 0  // Make preventing escape the main objective
		wm_set_main_objective 4 1  // Make escaping the main objective

		setstate goldbars_toi invisible

	}

	trigger truck_escape_msg
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_truck_stop"

		wm_addteamvoiceannounce 1 "allies_hq_truck_escort"

		wm_teamvoiceannounce 0 "goldrush_axis_truck_stolen"

		wm_teamvoiceannounce 1 "goldrush_allies_truck_stolen"
		// *---------------------------------------------------------------------------------*
	}

	// ========================================
	// movement

	trigger move_check
	{
		trigger truck stuck_check
		accum 1 abort_if_bitset 3

		trigger truck dispatch
	}

	trigger move
	{
		trigger truck move_check

		wait 500

		trigger truck move
	}

	// ========================================
	// ========================================


	trigger run_continue
	{
		trigger truck deathcheck
		trigger truck stopcheck
		trigger truck move
	}

	trigger run_1
	{
		accum 1 bitset 2
		followspline 0 tspln_1 150 wait length 304 wait roll 0 2 dampin
		accum 1 bitreset 2

		accum 3 set 1

		trigger truck run_continue
	}

	trigger run_2
	{
		accum 1 bitset 2
		followspline 0 tspln_2 150 wait length 304 wait roll 2 -1 dampout
		accum 1 bitreset 2

		accum 3 set 2
		trigger truck run_continue
	}

	trigger run_3
	{
		accum 1 bitset 2
		followspline 0 tspln_3 150 wait length 304 wait roll 1 -1 dampout
		accum 1 bitreset 2

		accum 3 set 3

		trigger truck run_continue
	}

	trigger run_4
	{
		accum 1 bitset 2
		followspline 0 tspln_4 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 4
		trigger truck run_continue
	}

	trigger run_5
	{


		accum 1 bitset 2
		followspline 0 tspln_5 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 5
		trigger truck run_continue
	}

	trigger run_6
	{


		accum 1 bitset 2
		followspline 0 tspln_6 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 6
		
	
		trigger truck run_continue
	}

	trigger run_7
	{

		trigger truck stuck_check_barrier3_built_msg
		
		accum 1 bitset 2
		followspline 0 tspln_7 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 7
		trigger truck run_continue
	}

	trigger run_8
	{
		
		accum 1 bitset 2
		followspline 0 tspln_8 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 8
		trigger truck run_continue
	}

	trigger run_9
	{
		
		accum 1 bitset 2
		followspline 0 tspln_9 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 9
		trigger truck run_continue
	}

	trigger run_10
	{

		accum 1 bitset 2
		followspline 0 tspln_10 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 10
		trigger truck run_continue
	}

	trigger run_11
	{
		
		// **************************
		trigger defense3 remove
		// **************************
		
		accum 1 bitset 2
		followspline 0 tspln_11 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 11
		trigger truck run_continue
	}

	trigger run_12
	{
		// antman removed the barrier announcements

		// *----------------------------------- vo ------------------------------------------*
		//wm_teamvoiceannounce 0 "goldrush_axis_truck_barrier1"

		//wm_teamvoiceannounce 1 "goldrush_allies_truck_barrier1"
		// *---------------------------------------------------------------------------------*

				
		accum 1 bitset 2
		followspline 0 tspln_12 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 12
		trigger truck run_continue
	}

	trigger run_13
	{

				
		accum 1 bitset 2
		followspline 0 tspln_13 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 13
		trigger truck run_continue
	}

	trigger run_14
	{
		
		
		accum 1 bitset 2
		followspline 0 tspln_14 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 14
		trigger truck run_continue
	}

	trigger run_15
	{
		trigger truck stuck_check_barrier5_built_msg
		
		accum 1 bitset 2
		followspline 0 tspln_15 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 15
		trigger truck run_continue
	}

	trigger run_16
	{
		
		accum 1 bitset 2
		followspline 0 tspln_16 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 16
		trigger truck run_continue
	}

	trigger run_17
	{
		
		accum 1 bitset 2
		followspline 0 tspln_17 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 17
	

		trigger truck run_continue
	}

	trigger run_18
	{
		
		accum 1 bitset 2
		followspline 0 tspln_18 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 18
		trigger truck run_continue
	}

	trigger run_19
	{


		accum 1 bitset 2
		followspline 0 tspln_19 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 19
		trigger truck run_continue
	}

	trigger run_20
	{
		accum 1 bitset 2
		followspline 0 tspln_20 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 20
		trigger truck run_continue
	}

	trigger run_21
	{
		accum 1 bitset 2
		followspline 0 tspln_21 150 wait length 304
		accum 1 bitreset 2

		// mortis
    		setautospawn "Allied House"	1  //Change spawn to initial spawn 
		wm_announce "Allies are attempting to send in reinforcements from the initial spawn!"

		accum 3 set 21
		trigger truck run_continue
	}

	trigger run_22
	{
		accum 1 bitset 2
		followspline 0 tspln_22 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 22
		globalaccum 2 set 1
		
		trigger axissecond_obj on 
		setautospawn "Allied House"	1  //Change spawn to initial spawn   
					
		trigger truck run_continue
	}

	trigger run_23
	{
		accum 1 bitset 2
		followspline 0 tspln_23 150 wait length 304
		accum 1 bitreset 2
				
		accum 3 set 23
		
		trigger truck run_continue
	}
	trigger run_24
	{
		accum 1 bitset 2
		followspline 0 tspln_24 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 24
		trigger truck run_continue
	}
	trigger run_25
	{
		accum 1 bitset 2
		followspline 0 tspln_25 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 25
		trigger truck run_continue
	}
	trigger run_26
	{
		accum 1 bitset 2
		followspline 0 tspln_26 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 26
		trigger truck run_continue
	}
	trigger run_27
	{
		accum 1 bitset 2
		followspline 0 tspln_27 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 27
		trigger truck run_continue
	}
	trigger run_28
	{
		accum 1 bitset 2
		followspline 0 tspln_28 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 28
		trigger truck run_continue
	}
	trigger run_29
	{
		accum 1 bitset 2
		followspline 0 tspln_29 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 29
		trigger truck run_continue
	}
	trigger run_30
	{
		accum 1 bitset 2
		followspline 0 tspln_30 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 30
		trigger truck run_continue
	}
	trigger run_31
	{
		accum 1 bitset 2
		followspline 0 tspln_31 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 31
		trigger truck run_continue
	}
	trigger run_32
	{
		accum 1 bitset 2
		followspline 0 tspln_32 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 32
		trigger truck stuck_check_barrier4_built_msg
		
		trigger truck run_continue
	}
	trigger run_33
	{
		accum 1 bitset 2
		followspline 0 tspln_33 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 33
		trigger truck run_continue
	}
	trigger run_34
	{
		
	
		accum 1 bitset 2
		followspline 0 tspln_34 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 34
		trigger truck run_continue
	}
	trigger run_35
	{

		// **************************
		trigger defense4 remove
		// **************************
				
		accum 1 bitset 2
		followspline 0 tspln_35 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 35
			
		trigger truck run_continue
	}
	trigger run_36
	{
		// antman removed the barrier announcements

		// *----------------------------------- vo ------------------------------------------*
		//wm_teamvoiceannounce 0 "goldrush_axis_truck_barrier2"

		//wm_teamvoiceannounce 1 "goldrush_allies_truck_barrier2"
		// *---------------------------------------------------------------------------------*
		
		accum 1 bitset 2
		followspline 0 tspln_36 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 36
		trigger truck run_continue
	}
	trigger run_37
	{
		accum 1 bitset 2
		followspline 0 tspln_37 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 37
		trigger truck run_continue
	}
	trigger run_38
	{
		accum 1 bitset 2
		followspline 0 tspln_38 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 38
		trigger truck run_continue
	}
	trigger run_39
	{
		accum 1 bitset 2
		followspline 0 tspln_39 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 39
		trigger truck run_continue
	}
	trigger run_40
	{
		accum 1 bitset 2
		followspline 0 tspln_40 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 40
		trigger truck run_continue
	}
	trigger run_41
	{
		accum 1 bitset 2
		followspline 0 tspln_41 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 41
		trigger truck run_continue
	}
	trigger run_42
	{
		accum 1 bitset 2
		followspline 0 tspln_42 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 42
		trigger truck run_continue
	}
	trigger run_43
	{
		accum 1 bitset 2
		followspline 0 tspln_43 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 43
		trigger truck run_continue
	}
	trigger run_44
	{
		accum 1 bitset 2
		followspline 0 tspln_44 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 44
		trigger truck run_continue
	}
	trigger run_45
	{
		accum 1 bitset 2
		followspline 0 tspln_45 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 45
		trigger truck run_continue
	}
	trigger run_46
	{
		accum 1 bitset 2
		followspline 0 tspln_46 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 46
		trigger truck run_continue
	}
	trigger run_47
	{
		accum 1 bitset 2
		followspline 0 tspln_47 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 47
		trigger truck run_continue
	}
	trigger run_48
	{
		accum 1 bitset 2
		followspline 0 tspln_48 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 48
		trigger truck run_continue
	}
	trigger run_49
	{
		accum 1 bitset 2
		followspline 0 tspln_49 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 49
		trigger truck run_continue
	}
	trigger run_50
	{
		accum 1 bitset 2
		followspline 0 tspln_50 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 50
		trigger truck run_continue
	}
	trigger run_51
	{
		accum 1 bitset 2
		followspline 0 tspln_51 150 wait length 304
		accum 1 bitreset 2

		accum 3 set 51
		
		trigger truck wheels_stop
		trigger truck_engine stop

		trigger game_manager allies_win
		
	}
	
	

	trigger dispatch
	{
		accum 3 trigger_if_equal 0 	truck run_1
		accum 3 trigger_if_equal 1 	truck run_2
		accum 3 trigger_if_equal 2	truck run_3
		accum 3 trigger_if_equal 3 	truck run_4
		accum 3 trigger_if_equal 4 	truck run_5
		accum 3 trigger_if_equal 5 	truck run_6
		accum 3 trigger_if_equal 6 	truck run_7
		accum 3 trigger_if_equal 7 	truck run_8
		accum 3 trigger_if_equal 8 	truck run_9
		accum 3 trigger_if_equal 9 	truck run_10
		accum 3 trigger_if_equal 10	truck run_11
		accum 3 trigger_if_equal 11	truck run_12
		accum 3 trigger_if_equal 12	truck run_13
		accum 3 trigger_if_equal 13	truck run_14
		accum 3 trigger_if_equal 14	truck run_15
		accum 3 trigger_if_equal 15	truck run_16
		accum 3 trigger_if_equal 16	truck run_17
		accum 3 trigger_if_equal 17	truck run_18
		accum 3 trigger_if_equal 18	truck run_19
		accum 3 trigger_if_equal 19	truck run_20
		accum 3 trigger_if_equal 20	truck run_21
		accum 3 trigger_if_equal 21	truck run_22
		accum 3 trigger_if_equal 22	truck run_23
		accum 3 trigger_if_equal 23	truck run_24
		accum 3 trigger_if_equal 24	truck run_25
		accum 3 trigger_if_equal 25	truck run_26
		accum 3 trigger_if_equal 26	truck run_27
		accum 3 trigger_if_equal 27	truck run_28
		accum 3 trigger_if_equal 28	truck run_29
		accum 3 trigger_if_equal 29	truck run_30
		accum 3 trigger_if_equal 30	truck run_31
		accum 3 trigger_if_equal 31	truck run_32
		accum 3 trigger_if_equal 32	truck run_33
		accum 3 trigger_if_equal 33	truck run_34
		accum 3 trigger_if_equal 34	truck run_35
		accum 3 trigger_if_equal 35	truck run_36
		accum 3 trigger_if_equal 36	truck run_37
		accum 3 trigger_if_equal 37	truck run_38
		accum 3 trigger_if_equal 38	truck run_39
		accum 3 trigger_if_equal 39	truck run_40
		accum 3 trigger_if_equal 40	truck run_41
		accum 3 trigger_if_equal 41	truck run_42
		accum 3 trigger_if_equal 42	truck run_43
		accum 3 trigger_if_equal 43	truck run_44
		accum 3 trigger_if_equal 44	truck run_45
		accum 3 trigger_if_equal 45	truck run_46
		accum 3 trigger_if_equal 46	truck run_47
		accum 3 trigger_if_equal 47	truck run_48
		accum 3 trigger_if_equal 48	truck run_49
		accum 3 trigger_if_equal 49	truck run_50
		accum 3 trigger_if_equal 50	truck run_51
	
	}

	// ========================================
	// barrier checking
	// digibob: since we cant return variables, just use bit 3 of accum 1 as a register... mmmm assembly......

	trigger stuck_check
	{
		accum 1 bitreset 3

		trigger truck stuck_check_gold
		trigger truck stuck_check_barrier3
		trigger truck stuck_check_barrier4
		trigger truck stuck_check_barrier5
		trigger truck stuck_check_scriptlockout
		trigger truck stuck_check_finished
	}

	trigger stuck_check_finished
	{
		accum 3 abort_if_not_equal 51

		accum 1 bitset 3
	}

	trigger stuck_check_scriptlockout
	{
		accum 1 abort_if_not_bitset 4

		accum 1 bitset 3
	}

	trigger stuck_check_gold
	{
		accum 3 abort_if_not_equal 0

		accum 0 abort_if_greater_than 0

		accum 1 bitset 3
	}

	trigger stuck_check_barrier3
	{
		accum 3 abort_if_not_equal 10

		accum 1 abort_if_not_bitset 0

		accum 1 bitset 3
	}

	trigger stuck_check_barrier3_built_msg
	{
		accum 1 abort_if_not_bitset 0

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "goldrush_allies_truckbar_destroy"
		// *---------------------------------------------------------------------------------*
	}

	trigger stuck_check_barrier4
	{
		accum 3 abort_if_not_equal 34

		accum 1 abort_if_not_bitset 1

		accum 1 bitset 3
	}
	
	trigger stuck_check_barrier5
	{
		accum 3 abort_if_not_equal 18

		accum 5 abort_if_not_equal 0  //Don't stop unless main gate whole

		accum 1 bitset 3
	}

	trigger stuck_check_barrier4_built_msg
	{
		accum 1 abort_if_not_bitset 1

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 1 "goldrush_allies_truckbar_destroy"
		// *---------------------------------------------------------------------------------*
	}
	
	trigger stuck_check_barrier5_built_msg
	{
		accum 5 abort_if_not_equal 0  //Abort if main entrance is blown

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_entrance1_defend"
		wm_teamvoiceannounce 1 "radar_allies_entrance1_destroy"
		// *---------------------------------------------------------------------------------*
	}

	// ========================================
	// ========================================




	// ========================================
	// stop check

	trigger stopcheck_setup
	{
		accum 1 bitset 6				// stop if we're stuck/no-one's pushing :)

		accum 1 abort_if_bitset 8		// no one in the trigger, abort

		trigger truck stuck_check		// call the stop check function
		accum 1 abort_if_bitset 3		// we're stuck so break out

		accum 1 bitreset 6				// we're free to keep going
	}

	trigger stopcheck
	{
		trigger truck stopcheck_setup
		accum 1 abort_if_not_bitset 6

		trigger truck script_lockout

		// Any just stopped moving stuff goes here
		trigger truck_engine stop
		trigger truck 		wheels_stop
		// <<<<< stop animation goes here

		trigger truck script_lockout_stop
		resetscript
	}

	// ========================================
	// ========================================




	// ========================================
	// script lockouts

	trigger script_lockout
	{
		accum 1 bitset 4
	}

	trigger script_lockout_stop
	{
		accum 1 bitreset 4
	}

	// ========================================
	// ========================================


	// ========================================
	// enable/disable

	trigger truck_enable
	{
		trigger truck stuck_check
		accum 1 abort_if_bitset 3 	// stuck check

		accum 4 set 0				// reset stop counter
		accum 1 bitreset 8			// reset stop check

		accum 1 abort_if_bitset 2 	// already following spline
		accum 1 abort_if_bitset 4 	// script lockout

		accum 1 abort_if_bitset 7 	// death check

		// Any just started moving stuff goes here
		trigger truck_engine start
		trigger truck wheels_forward
		// <<<<< start animation goes here
		trigger truck move
	}

	trigger truck_disable
	{
		accum 4 inc 1				// up the stop counter
		accum 4 abort_if_less_than 2

		accum 1 bitset 8			// set stop check

		trigger truck deathcheck
	}

	// ========================================
	// ========================================

	// ========================================
	// death / rebirth

	rebirth
	{
		accum 1 bitreset 7 // we're alive again
		accum 1 bitreset 9 // we're visibly alive

		changemodel models/mapobjects/blitz_sd/blitzbody.md3

		setstate truck_smoke invisible

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_truck_repaired_allies"

		wm_teamvoiceannounce 1 "allies_hq_truck_repaired"
		// *---------------------------------------------------------------------------------*

		trigger truck move
	}

	death
	{
		accum 1 bitset 7
	}

	trigger deathcheck
	{
		accum 1 abort_if_not_bitset 7	// are we dead?
		accum 1 abort_if_bitset 9		// are we not already visibly dead?
		accum 1 abort_if_bitset 2		// are we not following a spline?
		accum 1 abort_if_bitset 4		// are we not in a script lockout?

		accum 1 bitset 9				// we're now visibly dead

		wm_announce "The Truck has been damaged!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_truck_damaged"

		wm_teamvoiceannounce 1 "allies_hq_truck_damaged_axis"
		// *---------------------------------------------------------------------------------*

		setstate truck_smoke default
		kill truck_construct

		trigger truck_engine sound_death
		//trigger truck tracks_stop		// truck with tracks? i don't think so
		trigger truck wheels_stop
		// <<<< stop anim goes here

		changemodel models/mapobjects/blitz_sd/blitzbody_damaged.md3

		resetscript
	}

	// ========================================
	// ========================================




	// ========================================
	// barriers

	trigger enable_stage1
	{
		accum 1 bitreset 0
	}

	trigger disable_stage1
	{
		accum 1 bitset 0
	}

	trigger enable_stage2
	{
		accum 1 bitreset 1
	}

	trigger disable_stage2
	{
		accum 1 bitset 1
	}
	
	trigger enable_stage3
	{
		
		accum 5 set 1   // The main gate is destroyed
		trigger truck stuck_check  
	}
	
	trigger disable_stage3
	{
		accum 5 set 0 // The main gate is not destroyed
	
	}

}

truck_bwheel2
{
	spawn
	{
		wait 500

		attachtotag truck tag_wback
	}

	trigger forward
	{
		setrotation 130 0 0
	}

	trigger backward
	{
		setrotation -130 0 0
	}

	trigger stop
	{
		stoprotation
	}
}

truck_fwheel
{
	spawn
	{
		wait 500

		attachtotag truck tag_wfront
	}

	trigger forward
	{
		setrotation 130 0 0
	}

	trigger backward
	{
		setrotation -130 0 0
	}

	trigger stop
	{
		stoprotation
	}
}

truck_trigger
{
	spawn
	{
		wait 500

		attachtotag truck tag_wback
	}
}

truck_disabler
{
	trigger run
	{
		trigger truck truck_disable
	}
}

truck_enabler
{
	trigger run
	{
		trigger truck truck_disable
	}
}

defense3
{
	spawn
	{
		wait 400
		// mortis disable barrier 3 - materials - toi - disable speaker
		//trigger defense3 setup
		disablespeaker barrier1_flap
		setstate defense3_toi invisible
		setstate defense3_materials invisible
		setstate defense3_materials_clip invisible
		setstate defense3_flag invisible
		setstate defense3_wire invisible
		setstate defense3_hurt invisible
		setstate defense3_teeth2 invisible

		constructible_class 3
	}

	trigger setup
	{
		setstate defense3_materials invisible
		setstate defense3_materials_clip invisible
		setstate defense3_flag invisible


		setstate defense3_wire invisible
		setstate defense3_hurt invisible
		setstate defense3_teeth2 invisible
	}

	buildstart final
	{
		setstate defense3_materials default
		setstate defense3_materials_clip default
		setstate defense3_flag default


		setstate defense3_wire underconstruction
		setstate defense3_hurt underconstruction
		setstate defense3_teeth2 underconstruction
	}

	built final
	{
		setstate defense3_materials invisible
		setstate defense3_materials_clip invisible
		setstate defense3_flag invisible


		setstate defense3_wire default
		setstate defense3_hurt default
		setstate defense3_teeth2 default

		disablespeaker barrier1_flap
		trigger truck disable_stage1
		

		wm_announce "Truck Barrier #1 has been constructed."

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "goldrush_axis_truckbar_
"

		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbar_construct"
		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbars_construct"
		// *---------------------------------------------------------------------------------*

		
	}

	decayed final
	{
		setstate defense3_materials default
		setstate defense3_materials_clip default
		setstate defense3_flag default


		setstate defense3_wire invisible
		setstate defense3_hurt invisible
		setstate defense3_teeth2 invisible
	}

	death
	{
		setstate defense3_materials default
		setstate defense3_materials_clip default
		setstate defense3_flag default


		setstate defense3_wire invisible
		setstate defense3_hurt invisible
		setstate defense3_teeth2 invisible
		enablespeaker barrier1_flap
		trigger truck enable_stage1

		wm_announce "Truck Barrier #1 has been destroyed."

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "goldrush_axis_truckbar_construct"

		wm_teamvoiceannounce 0 "goldrush_axis_truckbar_destroyed"

		wm_teamvoiceannounce 1 "goldrush_allies_truckbar_destroyed"
		// *---------------------------------------------------------------------------------*
	}

	trigger remove
	{
		setstate defense3_toi invisible
		setstate defense3_materials invisible
		setstate defense3_materials_clip invisible
		setstate defense3_flag invisible
		setstate defense3_wire invisible
		setstate defense3_hurt invisible
		setstate defense3_teeth2 invisible
	}
}

defense4
{
	spawn
	{
		wait 400
		//mortis - eliminate barrier #2 - disable speaker - hide materials - hide toi
		//trigger defense4 setup

		setstate defense4_wire invisible
		setstate defense4_hurt invisible
		setstate defense4_teeth1 invisible
		setstate defense4_teeth2 invisible
		setstate defense4_materials invisible
		setstate defense4_materials_clip invisible
		setstate defense4_flag invisible
		setstate defense4_toi invisible
		disablespeaker barrier2_flap
		constructible_class 3
	}

	trigger setup
	{

		setstate defense4_materials invisible
		setstate defense4_materials_clip invisible
		setstate defense4_flag invisible


		setstate defense4_wire invisible
		setstate defense4_hurt invisible
		setstate defense4_teeth1 invisible
		setstate defense4_teeth2 invisible
	}

	buildstart final
	{
		setstate defense4_materials default
		setstate defense4_materials_clip default
		setstate defense4_flag default


		setstate defense4_wire underconstruction
		setstate defense4_hurt underconstruction
		setstate defense4_teeth1 underconstruction
		setstate defense4_teeth2 underconstruction
	}

	built final
	{
		setstate defense4_materials invisible
		setstate defense4_materials_clip invisible
		setstate defense4_flag invisible


		setstate defense4_wire default
		setstate defense4_hurt default
		setstate defense4_teeth1 default
		setstate defense4_teeth2 default

		trigger truck disable_stage2
		disablespeaker barrier2_flap
		wm_announce "Truck Barrier #2 has been constructed."

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "goldrush_axis_truckbar_constructed"

		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbar_construct"
		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbars_construct"
		// *---------------------------------------------------------------------------------*
	}

	decayed final
	{
		setstate defense4_materials default
		setstate defense4_materials_clip default
		setstate defense4_flag default


		setstate defense4_wire invisible
		setstate defense4_hurt invisible
		setstate defense4_teeth1 invisible
		setstate defense4_teeth2 invisible
	}

	death
	{
		setstate defense4_materials default
		setstate defense4_materials_clip default
		setstate defense4_flag default
		enablespeaker barrier2_flap

		setstate defense4_wire invisible
		setstate defense4_hurt invisible
		setstate defense4_teeth1 invisible
		setstate defense4_teeth2 invisible

		trigger truck enable_stage2

		wm_announce "Truck Barrier #2 has been destroyed."

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "goldrush_axis_truckbar_construct"

		wm_teamvoiceannounce 0 "goldrush_axis_truckbar_destroyed"

		wm_teamvoiceannounce 1 "goldrush_allies_truckbar_destroyed"
		// *---------------------------------------------------------------------------------*
	}

	trigger remove
	{
		setstate defense4_toi invisible
		setstate defense4_materials invisible
		setstate defense4_materials_clip invisible
		setstate defense4_flag invisible
		setstate defense4_wire invisible
		setstate defense4_hurt invisible
		setstate defense4_teeth1 invisible
		setstate defense4_teeth2 invisible

		// *----------------------------------- vo ------------------------------------------*
		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbar_construct"
		wm_removeteamvoiceannounce 0 "goldrush_axis_truckbars_construct"

		wm_removeteamvoiceannounce 1 "goldrush_allies_truckbar_destroy"
		wm_removeteamvoiceannounce 1 "goldrush_allies_truckbars_destroy"
		// *---------------------------------------------------------------------------------*
	}
}


// *********************************************
// ****************** FLAG STUFF ***************
// *********************************************

goldbar_holder
{
		
	death
	{
		trigger truck add_goldbar

	}
}


// *********************************************
// ****************** GOLD STUFF ***************
// *********************************************

gold_crate
{
	spawn
	{
		accum 0 set 0 // gold counter
	}

	trigger stolen
	{
		accum 0 inc 1
		accum 0 trigger_if_equal 1 gold_crate stolen1
	}
	
	trigger secured
	{
		accum 0 trigger_if_equal 1 gold_crate secured1
	}
	
	trigger returned
	{
		accum 0 inc -1
		accum 0 trigger_if_equal 0 gold_crate returned1
	}
	
	trigger stolen1
	{
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_radarw_taken"

		wm_teamvoiceannounce 1 "radar_allies_radarw_taken"
		// *---------------------------------------------------------------------------------*		
		trigger radartower stoprotate
	}
	
	trigger secured1
	{
		wm_announce "Allied team has secured the Radar Parts!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_radarw_lost"
		wm_teamvoiceannounce 1 "radar_allies_radarw_secured"
		wm_removeteamvoiceannounce 1 "radar_allies_radars_steal"  //Removed as no longer needed
		wm_removeteamvoiceannounce 0 "radar_axis_radars_defend"  //Removed as no longer needed
		// *---------------------------------------------------------------------------------*
	setstate goldbars_cm_marker invisible
	}
	
	trigger returned1
	{
		trigger radartower startrotate
		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_radarw_returned"

		wm_teamvoiceannounce 1 "radar_allies_radarw_returned"
		// *---------------------------------------------------------------------------------*
	}

}

gold_full_0
{
	spawn
	{
		wait 500
		attachtotag truck tag_obj1
		faceangles 0 90 0 50

		setstate gold_full_0 invisible
	}

	trigger show
	{
		setstate gold_full_0 default
	}
}



gold_trans_0
{
	spawn
	{
		wait 500
		attachtotag truck tag_obj1
		faceangles 0 90 0 50
	}

	trigger hide
	{
		setstate gold_trans_0 invisible
	}
}



radartower
{
	spawn
	{
	playsound sound/world/radio_static_01.wav looping
	trigger radartower rotateloop
	}
	
	trigger rotateloop
	{
		faceangles 0 -90 0 3500
		faceangles 0 -180 0 3500
		faceangles 0 -270 0 3500
		faceangles 0 -360 0 3500
		trigger radartower rotateloop
	}
	
	trigger destroyed
	{
		stopsound
		halt
	}
	
	trigger startrotate
	{
		playsound sound/world/radio_static_01.wav looping
		faceangles 0 -90 0 3500
		faceangles 0 -180 0 3500
		faceangles 0 -270 0 3500
		faceangles 0 -360 0 3500
		trigger radartower start
	}
	trigger stoprotate
	{
		stopsound
		halt
	}
}



axis_radio_destroyed 
{ 
   spawn 
   { 
      wait 400 
      setstate axis_radio_destroyed invisible 
      setstate axis_radio_destroyed_model invisible 
   } 

   trigger hide 
   { 
      setstate axis_radio_destroyed invisible 
      setstate axis_radio_destroyed_model invisible 
   } 

   trigger show 
   { 
      accum 6 abort_if_equal 0 
      setstate axis_radio_destroyed default 
      setstate axis_radio_destroyed_model default 
   } 

   trigger enable 
   { 
      accum 6 set 1 
   } 
} 

axis_radio_closed 
{ 
   trigger hide 
   { 
      setstate axis_radio_closed invisible 
      setstate axis_radio_closed_model invisible 
   } 

   trigger show 
   { 
      accum 6 abort_if_equal 1 
      setstate axis_radio_closed default 
      setstate axis_radio_closed_model default 
   } 

   trigger disable 
   { 
      accum 6 set 1 
   } 
} 

axis_radio_built 
{ 
   spawn 
   { 
      wait 400 

      constructible_class 2 

      trigger axis_radio_built setup 
   } 

   trigger setup 
   { 
      setchargetimefactor 0 soldier 1 
      setchargetimefactor 0 lieutenant 1 
      setchargetimefactor 0 medic 1 
      setchargetimefactor 0 engineer 1 
      setchargetimefactor 0 covertops 1 
      sethqstatus 0 0 
   } 

   buildstart final 
   { 
      trigger axis_radio_built_model trans 

      trigger axis_radio_destroyed hide 
      trigger axis_radio_closed    hide 
   } 

   built final 
   { 
      trigger axis_radio_built_model show 

      trigger axis_radio_destroyed enable 
      trigger axis_radio_closed    disable 

      trigger axis_radio_built_model enable_axis_features 
  
   } 

   decayed final 
   { 
      trigger axis_radio_built_model hide 

      trigger axis_radio_destroyed show 
      trigger axis_radio_closed    show 
   } 

   death 
   { 
      trigger axis_radio_built_model hide 

      trigger axis_radio_destroyed show 

      trigger axis_radio_built_model disable_axis_features 

      
   } 
} 

axis_radio_built_model 
{ 
   spawn 
   { 
      wait 400 
      setstate axis_radio_built_model invisible 
   } 

   trigger show 
   { 
      setstate axis_radio_built_model default 
   } 

   trigger hide 
   { 
      setstate axis_radio_built_model invisible 
   } 

   trigger trans 
   { 
      setstate axis_radio_built_model underconstruction 
   } 

   trigger enable_axis_features 
   { 
      setchargetimefactor 0 soldier 0.75
      setchargetimefactor 0 lieutenant 0.75 
      setchargetimefactor 0 medic 0.75 
      setchargetimefactor 0 engineer 0.75 
      setchargetimefactor 0 covertops 0.75 
      enablespeaker axis_compost_sound
      sethqstatus 0 1 
   	playsound textures/snatch_beta/radio_axis.wav looping

      
      wm_announce   "Axis Command Post constructed. Charge speed increased!" 

      // *----------------------------------- vo ------------------------------------------* 
      wm_teamvoiceannounce 0 "axis_hq_compost_constructed" 

      wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis" 

      wm_removeteamvoiceannounce 0 "axis_hq_compost_construct" 
      // *----------------------------------- vo ------------------------------------------* 

      wm_objective_status 6 0 1 
      wm_objective_status 6 1 0 

   } 

   trigger disable_axis_features 
   { 
 
      wm_announce   "Allied team has destroyed the Axis Command Post!" 

      // *----------------------------------- vo ------------------------------------------* 
      wm_addteamvoiceannounce 0 "axis_hq_compost_construct" 

      wm_teamvoiceannounce 0 "axis_hq_compost_damaged" 
      // *----------------------------------- vo ------------------------------------------* 

      setchargetimefactor 0 soldier 1
      setchargetimefactor 0 lieutenant 1 
      setchargetimefactor 0 medic 1
      setchargetimefactor 0 engineer 1
      setchargetimefactor 0 covertops 1
      stopsound
      sethqstatus 0 0 
      


      wm_objective_status 6 0 0 
      wm_objective_status 6 1 1 
   } 
}

allied_radio_destroyed 
{ 
   spawn 
   { 
      wait 400 
      setstate allied_radio_destroyed invisible 
      setstate allied_radio_destroyed_model invisible 
   } 

   trigger hide 
   { 
      setstate allied_radio_destroyed invisible 
      setstate allied_radio_destroyed_model invisible 
   } 

   trigger show 
   { 
      accum 5 abort_if_equal 0 
      setstate allied_radio_destroyed default 
      setstate allied_radio_destroyed_model default 
   } 

   trigger enable 
   { 
      accum 5 set 1 
   } 
} 

allied_radio_closed 
{ 
   trigger hide 
   { 
      setstate allied_radio_closed invisible 
      setstate allied_radio_closed_model invisible 
   } 

   trigger show 
   { 
      accum 5 abort_if_equal 1 
      setstate allied_radio_closed default 
      setstate allied_radio_closed_model default 
   } 

   trigger disable 
   { 
      accum 5 set 1 
   } 
} 

allied_radio_built 
{ 
   spawn 
   { 
      wait 400 

      constructible_class 2 

      trigger allied_radio_built setup 
   } 

   trigger setup 
   { 
      setchargetimefactor 1 soldier 1 
      setchargetimefactor 1 lieutenant 1 
      setchargetimefactor 1 medic 1 
      setchargetimefactor 1 engineer 1 
      setchargetimefactor 1 covertops 1 
      sethqstatus 1 0 
   } 

   buildstart final 
   { 
      trigger allied_radio_built_model trans 

      trigger allied_radio_destroyed hide 
      trigger allied_radio_closed    hide 
   } 

   built final 
   { 
      trigger allied_radio_built_model show 

      trigger allied_radio_destroyed enable 
      trigger allied_radio_closed    disable 

      trigger allied_radio_built_model enable_allied_features 


   } 

   decayed final 
   { 
      trigger allied_radio_built_model hide 

      trigger allied_radio_destroyed show 
      trigger allied_radio_closed    show 
   } 

   death 
   { 
      trigger allied_radio_built_model hide 

      trigger allied_radio_destroyed show 

      trigger allied_radio_built_model disable_allied_features 


   } 
} 

allied_radio_built_model 
{ 
   spawn 
   { 
      wait 400 
      setstate allied_radio_built_model invisible 
   } 

   trigger show 
   { 
      setstate allied_radio_built_model default 
   } 

   trigger hide 
   { 
      setstate allied_radio_built_model invisible 
   } 

   trigger trans 
   { 
      setstate allied_radio_built_model underconstruction 
   } 

   trigger enable_allied_features 
   { 
      setchargetimefactor 1 soldier 0.75
      setchargetimefactor 1 lieutenant 0.75
      setchargetimefactor 1 medic 0.75
      setchargetimefactor 1 engineer 0.75
      setchargetimefactor 1 covertops 0.75
      playsound textures/snatch_beta/radio_allies.wav looping
      sethqstatus 1 1 

      wm_announce   "Allied Command Post constructed. Charge speed increased!" 

      // *----------------------------------- vo ------------------------------------------* 
      wm_teamvoiceannounce 1 "allies_hq_compost_constructed" 

      wm_teamvoiceannounce 0 "allies_hq_compost_constructed_axis" 

      wm_removeteamvoiceannounce 1 "allies_hq_compost_construct" 
      // *----------------------------------- vo ------------------------------------------* 

      wm_objective_status 5 1 1 
      wm_objective_status 5 0 0 
      
      // trigger allied_radio_built_model change_spawn_cmd
	// mortis
	wait 50
	trigger snatchhq_obj on
	wm_announce "The Allied Forest House Spawn has been enabled!"
      
   } 

   trigger disable_allied_features 
   { 

      wm_announce   "Axis team has destroyed the Allied Command Post!" 

      // *----------------------------------- vo ------------------------------------------* 
      wm_addteamvoiceannounce 1 "allies_hq_compost_construct" 

      wm_teamvoiceannounce 1 "allies_hq_compost_damaged" 
      // *----------------------------------- vo ------------------------------------------* 

      setchargetimefactor 1 soldier 1
      setchargetimefactor 1 lieutenant 1 
      setchargetimefactor 1 medic 1
      setchargetimefactor 1 engineer 1 
      setchargetimefactor 1 covertops 1
      stopsound
      sethqstatus 1 0 
      wm_objective_status 5 1 0 
      wm_objective_status 5 0 1       

      // trigger allied_radio_built_model change_spawn
	// mortis
	wait 50
	trigger snatchhq_obj off
	wm_announce "The Allied Forest House Spawn has been disabled!"
	
   } 
   trigger change_spawn
   {
	   	
		//mortis - disable
	   	//setstate alsp2 invisible
	      	  
      	setautospawn "Allied House"	1  //Change spawn to initial spawn   
   		
	}
	
	trigger change_spawn_cmd
	{
		//mortis - disable
	 	//setstate alsp2 default
	  	globalaccum 2 abort_if_greater_than 0	
	  
	  	// Only set spawn to forest house if truck has not passed run_22, players can still select it.
      	setautospawn	"Forest House"	1  //Change spawn to command post
	
	}
   
   
} 

forestspawn_obj
{
	spawn
	{
		
		wait 50
		setstate forestspawn_obj invisible
		setstate forest_spawn invisible
	}

	trigger on
	{               
		setstate forestspawn_obj default
		setstate forest_spawn default
	}

	trigger off
	{
		setstate forestspawn_obj invisible
		setstate forest_spawn invisible
	}
}

axissecond_obj
{
	spawn
	{
		
		wait 50
		setstate axissecond_obj invisible
		setstate axis_second invisible
	}

	trigger on
	{               
		setstate axissecond_obj default
		setstate axis_second default
		setautospawn	"Storage"	0
	}

	trigger off
	{
		setstate axissecond_obj invisible
		setstate axis_second invisible
		setautospawn	"Base Spawn"	0
	}
}






allied_mg1_toi
{
}

allied_mg1
{
	spawn
	{
		wait 400
		constructible_class 3
		
		trigger allied_mg1 remove


	}


	trigger setup
	{
		setstate allied_mg1_materials default
		setstate allied_mg1_materials_clip default
		setstate allied_mg1_flag default
	}

	buildstart final
	{
		setstate allied_mg1_materials default
		setstate allied_mg1_materials_clip default
		setstate allied_mg1_flag default
	}

	built final
	{
		setstate allied_mg1_materials invisible
		setstate allied_mg1_materials_clip invisible
		setstate allied_mg1_flag invisible
	
		wm_teamvoiceannounce 1 "fueldump_allies_bridge_constructed"
				
		wm_teamvoiceannounce 0 "fueldump_axis_bridge_destroy"
		
		wm_removeteamvoiceannounce 1 "fueldump_allies_bridge_construct"  //Remove as bridge has been built
		
		wm_announce "Allies have constructed the Bridge!"
		
		disablespeaker bridge_flap1
		disablespeaker bridge_flap2
	}

	decayed final
	{
		setstate allied_mg1_materials default
		setstate allied_mg1_materials_clip default
		setstate allied_mg1_flag default
	}

	death
	{
		setstate allied_mg1_materials default
		setstate allied_mg1_materials_clip default
		setstate allied_mg1_flag default
		
		wm_teamvoiceannounce 1 "fueldump_allies_bridge_destroyed"
				
		wm_teamvoiceannounce 0 "fueldump_axis_bridge_destroyed"
		
		wm_addteamvoiceannounce 1 "fueldump_allies_bridge_construct"  //Add as bridge has been destroyed
		wm_teamvoiceannounce 1 "fueldump_allies_bridge_construct"
		
		wm_announce "The Bridge has been destroyed!"

		enablespeaker bridge_flap1
		enablespeaker bridge_flap2
				
	}

	trigger remove
	{
		setstate allied_mg1_toi invisible
		setstate allied_mg1_materials invisible
		setstate allied_mg1_materials_clip invisible
		setstate allied_mg1_flag invisible

		remove
	}
}

main_gate
{	
	spawn
	{
	wait 200
	remove
	
	trigger truck disable_stage3  //The main gate has not been destroyed
	
	}
	death
	{
	// setstate debris3 default
	wm_objective_status 3 0 2
	wm_objective_status 3 1 1
	
	// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_entrance1_destroyed"
		wm_teamvoiceannounce 1 "radar_allies_entrance1_destroyed"
	// *---------------------------------------------------------------------------------*

	wm_announce   "Allies has destroyed the Main Gate!"  	
	trigger truck enable_stage3
	}
}

construction_script 
{ 
   spawn 
   { 
      wait 400 
      constructible_class 2
      setstate construction_extra invisible 
      setstate construction_mg42  invisible 

	//mortis disable toi - speaker - materials
      setstate const_tower    invisible 
	setstate const_toi 	invisible
      disablespeaker forest_flap
   } 

   trigger setup 
   { 
      setstate construction_extra invisible 
      setstate construction_mg42  invisible 
      setstate const_tower        default 
   } 
   
   buildstart final 
   { 
	setstate construction_extra invisible 
    setstate construction_mg42  invisible 
    setstate const_tower        default 
	} 

   built final 
   { 
      setstate construction_extra default 
      setstate construction_mg42  default 
      setstate const_tower        invisible 
      disablespeaker forest_flap
	  
      // Some kind of UI pop-up to alert players 
		wm_announce   "Allied team has constructed the Forest House MG42!" 
   } 

   decayed final 
   { 
	setstate const_tower        default 
	setstate construction_extra invisible 
    setstate construction_mg42  invisible 
    
   } 

   death 
   { 
	  setstate construction_extra invisible 
      setstate construction_mg42  invisible 
      setstate const_tower        default 
      enablespeaker forest_flap
	  wm_announce   "Axis team has destroyed the Forest House MG42!"  
   } 
}


allied_mg
{
	spawn
	{
		wait 400
		trigger allied_mg remove
	}

	trigger setup
	{
		setstate allied_mg_materials default
		setstate allied_mg_materials_clip default
		setstate allied_mg_flag default
		setstate almg1 invisible
	}

	buildstart final
	{
		setstate allied_mg_materials default
		setstate allied_mg_materials_clip default
		setstate allied_mg_flag default
		setstate almg1 underconstruction
	}

	built final
	{
		setstate allied_mg_materials invisible
		setstate allied_mg_materials_clip invisible
		setstate allied_mg_flag invisible
		setstate almg1 default
		wm_announce "The Axis MG42 has been constructed!"
		disablespeaker axismg42_flap 
	
	}

	decayed final
	{
		setstate allied_mg_materials default
		setstate allied_mg_materials_clip default
		setstate allied_mg_flag default
		setstate almg1 invisible
	}

	death
	{
		setstate allied_mg_materials invisible
		setstate allied_mg_materials_clip invisible
		setstate allied_mg_flag invisible
		setstate almg1 invisible

	}

	trigger remove
	{
		setstate allied_mg_toi invisible
		setstate allied_mg_materials invisible
		setstate allied_mg_materials_clip invisible
		setstate allied_mg_flag invisible

		remove
	}
}

radiowall
{	
	spawn
	{
	wait 500
	setstate radiodebris invisible
	constructible_class 1
	}
	death
	{
	setstate radiodebris default
	wm_announce "The Radio Room wall has been destroyed!"
	wm_objective_status 7 0 2
	wm_objective_status 7 1 1

	}
}